package com.antler.smt.portal.controller;

import com.antler.smt.constant.RoleConstant;
import com.antler.smt.entity.JobOrderCommentEntity;
import com.antler.smt.portal.annotation.OperateCut;
import com.antler.smt.request.portal.JobOrderCommentReq;
import com.antler.smt.response.base.Result;
import com.antler.smt.service.portal.JobCommentService;
import com.antler.smt.utils.LogUtil;
import com.antler.smt.validate.DataValidator;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.xml.crypto.Data;

/**
 *  对工作的评价信息
 *
 * @author zhangyi
 * @date 2018/7/13 13:02
 */
@RestController
@RequestMapping("/job")
@Api(description = "对工作的评价接口")
public class JobCommentController extends BaseController{

    /**
     * 添加日志
     */
    private Logger log = LogUtil.get();

    @Resource
    private JobCommentService jobCommentService;

    /**
     * 插入评价信息
     *
     * @param req
     * @return
     */
    @PostMapping("/insertComment")
    @ApiOperation(value = "插入评价信息",httpMethod = "POST")
    @OperateCut(operationContent = "评价操作操作")
    public Result insertJobComment(JobOrderCommentReq req){
        DataValidator.isNull(req,"评价实体不能为空！");
        DataValidator.isBlank(req.getCommentPeople(),"对工人工程师评价不能为空！");
        DataValidator.isBlank(req.getCommentPlatform(),"对平台评价不能为空！");
        DataValidator.isBlank(String.valueOf(req.getCommentLevel()),"评价星级不能为空！");
        //插入发布者的id信息
        req.setRecruitmentId(currentMember.getId());
        return jobCommentService.insertComment(req);
    }

    /**
     *  获取评价信息实体
     *
     * @param recruitmentId
     * @return
     */
    @GetMapping("/comment/{RecruitmentId}")
    @ApiOperation(value = "获取评价信息",httpMethod = "GET")
    @OperateCut(operationContent = "评价操作操作")
    public Result selectComment(@PathVariable("RecruitmentId") Long recruitmentId){
        return jobCommentService.selectComment(recruitmentId,currentMember.getId());
    }

}
